package cn.iocoder.yudao.module.system.filter;

import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.filter.OncePerRequestFilter;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Objects;

/**
 * @author ext.gouying3
 * @date 2025/7/8
 */
public class TestFilter extends OncePerRequestFilter {


    @Override
    protected boolean shouldNotFilter(HttpServletRequest request) throws ServletException {
        System.out.println("test 不拦截");
        return request.getServletPath().matches("/test");
    }

    @Override
    protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {

        if(Objects.nonNull(request.getCookies())){
            for (Cookie cookie : request.getCookies()) {
                if(cookie.getName().equals("admin")){
                    System.out.println("admom");
                }
            }
        }
        filterChain.doFilter(request,response);
    }
}
